home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / src / plcvt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-30  |  3.8 KB  |  175 lines

  1. /* $Id: plcvt.c,v 1.4 1994/06/30 18:22:05 mjl Exp $
  2.  * $Log: plcvt.c,v $
  3.  * Revision 1.4  1994/06/30  18:22:05  mjl
  4.  * All core source files: made another pass to eliminate warnings when using
  5.  * gcc -Wall.  Lots of cleaning up: got rid of includes of math.h or string.h
  6.  * (now included by plplot.h), and other minor changes.  Now each file has
  7.  * global access to the plstream pointer via extern; many accessor functions
  8.  * eliminated as a result.
  9.  *
  10. */
  11.  
  12. /*    plcvt.c
  13.  
  14.     Coordinate transformation routines.
  15. */
  16.  
  17. #include "plplotP.h"
  18.  
  19. /*----------------------------------------------------------------------*\
  20.  *  Coordinate transformations for plotting package.
  21.  *  Conversion routines yielding an integer result.
  22. \*----------------------------------------------------------------------*/
  23.  
  24. /* device coords to physical coords (x) */
  25.  
  26. PLINT
  27. plP_dcpcx(PLFLT x)
  28. {
  29.     return (ROUND(plsc->dpxoff + plsc->dpxscl * x));
  30. }
  31.  
  32. /* device coords to physical coords (y) */
  33.  
  34. PLINT
  35. plP_dcpcy(PLFLT y)
  36. {
  37.     return (ROUND(plsc->dpyoff + plsc->dpyscl * y));
  38. }
  39.  
  40. /* millimeters from bottom left-hand corner to physical coords (x) */
  41.  
  42. PLINT
  43. plP_mmpcx(PLFLT x)
  44. {
  45.     return (ROUND(plsc->mpxoff + plsc->mpxscl * x));
  46. }
  47.  
  48. /* millimeters from bottom left-hand corner to physical coords (y) */
  49.  
  50. PLINT
  51. plP_mmpcy(PLFLT y)
  52. {
  53.     return (ROUND(plsc->mpyoff + plsc->mpyscl * y));
  54. }
  55.  
  56. /* world coords to physical coords (x) */
  57.  
  58. PLINT
  59. plP_wcpcx(PLFLT x)
  60. {
  61.     return (ROUND(plsc->wpxoff + plsc->wpxscl * x));
  62. }
  63.  
  64. /* world coords to physical coords (y) */
  65.  
  66. PLINT
  67. plP_wcpcy(PLFLT y)
  68. {
  69.     return (ROUND(plsc->wpyoff + plsc->wpyscl * y));
  70. }
  71.  
  72. /*----------------------------------------------------------------------*\
  73.  *  Coordinate transformations for plotting package.
  74.  *  Conversion routines yielding an floating result.
  75. \*----------------------------------------------------------------------*/
  76.  
  77. /* device coords to millimeters from bottom left-hand corner (x) */
  78.  
  79. PLFLT
  80. plP_dcmmx(PLFLT x)
  81. {
  82.     return ((PLFLT) (x * ABS(plsc->phyxma - plsc->phyxmi) / plsc->xpmm));
  83. }
  84.  
  85. /* device coords to millimeters from bottom left-hand corner (y) */
  86.  
  87. PLFLT
  88. plP_dcmmy(PLFLT y)
  89. {
  90.     return ((PLFLT) (y * ABS(plsc->phyyma - plsc->phyymi) / plsc->ypmm));
  91. }
  92.  
  93. /* define transformations between device coords and subpage coords (x) */
  94.  
  95. PLFLT
  96. plP_dcscx(PLFLT x)
  97. {
  98.     return ((PLFLT) ((x - plsc->spdxmi) / (plsc->spdxma - plsc->spdxmi)));
  99. }
  100.  
  101. /* define transformations between device coords and subpage coords (y) */
  102.  
  103. PLFLT
  104. plP_dcscy(PLFLT y)
  105. {
  106.     return ((PLFLT) ((y - plsc->spdymi) / (plsc->spdyma - plsc->spdymi)));
  107. }
  108.  
  109. /* millimeters from bottom left corner into device coords (x) */
  110.  
  111. PLFLT
  112. plP_mmdcx(PLFLT x)
  113. {
  114.     return ((PLFLT) (x * plsc->xpmm / ABS(plsc->phyxma - plsc->phyxmi)));
  115. }
  116.  
  117. /* millimeters from bottom left corner into device coords (y) */
  118.  
  119. PLFLT
  120. plP_mmdcy(PLFLT y)
  121. {
  122.     return ((PLFLT) (y * plsc->ypmm / ABS(plsc->phyyma - plsc->phyymi)));
  123. }
  124.  
  125. /* subpage coords to device coords (x) */
  126.  
  127. PLFLT
  128. plP_scdcx(PLFLT x)
  129. {
  130.     return ((PLFLT) (plsc->spdxmi + (plsc->spdxma - plsc->spdxmi) * x));
  131. }
  132.  
  133. /* subpage coords to device coords (y) */
  134.  
  135. PLFLT
  136. plP_scdcy(PLFLT y)
  137. {
  138.     return ((PLFLT) (plsc->spdymi + (plsc->spdyma - plsc->spdymi) * y));
  139. }
  140.  
  141. /* world coords into millimeters (x) */
  142.  
  143. PLFLT
  144. plP_wcmmx(PLFLT x)
  145. {
  146.     return ((PLFLT) (plsc->wmxoff + plsc->wmxscl * x));
  147. }
  148.  
  149. /* world coords into millimeters (y) */
  150.  
  151. PLFLT
  152. plP_wcmmy(PLFLT y)
  153. {
  154.     return ((PLFLT) (plsc->wmyoff + plsc->wmyscl * y));
  155. }
  156.  
  157. /* undocumented transformation for 3d plot routines (x) */
  158.  
  159. PLFLT
  160. plP_w3wcx(PLFLT x, PLFLT y, PLFLT z)
  161. {
  162.     return ((PLFLT) ((x - plsc->basecx) * plsc->cxx +
  163.              (y - plsc->basecy) * plsc->cxy));
  164. }
  165.  
  166. /* undocumented transformation for 3d plot routines (y) */
  167.  
  168. PLFLT
  169. plP_w3wcy(PLFLT x, PLFLT y, PLFLT z)
  170. {
  171.     return ((PLFLT) ((x - plsc->basecx) * plsc->cyx +
  172.              (y - plsc->basecy) * plsc->cyy +
  173.              (z - plsc->ranmi) * plsc->cyz));
  174. }
  175.